package com.yunze.web.controller.yunze.fhgl;

import com.alibaba.fastjson.JSON;
import com.yunze.common.utils.ServletUtils;
import com.yunze.common.utils.ip.IpUtils;
import com.yunze.common.utils.yunze.AesEncryptUtil;
import com.yunze.system.service.yunze.fhgl.OrderDelivery.IFhglOrderDeliveryService;
import com.yunze.web.core.config.MyBaseController;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;

/**
 * 发货管理 订单合同发货
 */
@RestController
@RequestMapping("/yunze/FhglOrderDelivery")
public class FhglOrderDeliveryController extends MyBaseController
{

    @Resource
    private IFhglOrderDeliveryService iFhglOrderDeliveryService;


    /**
     * 订单合同发货 列表
     */
    @PreAuthorize("@ss.hasPermi('yunze:FhglOrderDelivery:list')")
    @PostMapping(value = "/list", produces = { "application/json;charset=UTF-8" })
    public String list(@RequestBody String Pstr)
    {
        HashMap<String, Object> Parammap = new HashMap<String, Object>();
        if(Pstr!=null){
            Pstr = Pstr.replace("%2F", "/");//转义 /
        }
        try {
            Pstr =  AesEncryptUtil.desEncrypt(Pstr);
            Parammap.putAll(JSON.parseObject((String) Pstr));
            return MyRetunSuccess(iFhglOrderDeliveryService.selMap(Parammap),null);
        }catch (Exception e){
            String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
            logger.error("<br/>  FhglOrderDelivery/list  <br/> Pstr = " + Pstr + " <br/> ip =  " + ip + " <br/> ",e.getCause().toString());
        }
        return Myerr("获取订单合同发货 列表 操作失败！");
    }


    /**
     * 查询未完成的销售合同ID
     */
    @PostMapping(value = "/sel_CT_ID", produces = { "application/json;charset=UTF-8" })
    public String sel_CT_ID(@RequestBody String Pstr)
    {
        HashMap<String, Object> Parammap = new HashMap<String, Object>();
        if(Pstr!=null){
            Pstr = Pstr.replace("%2F", "/");//转义 /
        }
        try {
            Pstr =  AesEncryptUtil.desEncrypt(Pstr);
            Parammap.putAll(JSON.parseObject((String) Pstr));
            return MyRetunSuccess(iFhglOrderDeliveryService.sel_CT_ID(Parammap),null);
        }catch (Exception e){
            String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
            logger.error("<br/>  FhglOrderDelivery/sel_CT_ID  <br/> Pstr = " + Pstr + " <br/> ip =  " + ip + " <br/> ",e.getCause().toString());
        }
        return Myerr("获取 查询未完成的销售合同ID 操作失败！");
    }


    /**
     * 查询 合同发货信息 id
     */
    @PostMapping(value = "/Sle_ODYContractID", produces = { "application/json;charset=UTF-8" })
    public String Sle_ODYContractID(@RequestBody String Pstr)
    {
        HashMap<String, Object> Parammap = new HashMap<String, Object>();
        if(Pstr!=null){
            Pstr = Pstr.replace("%2F", "/");//转义 /
        }
        try {
            Pstr =  AesEncryptUtil.desEncrypt(Pstr);
            Parammap.putAll(JSON.parseObject((String) Pstr));
            return MyRetunSuccess(iFhglOrderDeliveryService.Sle_ODYContractID(Parammap),null);
        }catch (Exception e){
            String ip = IpUtils.getIpAddr(ServletUtils.getRequest());
            logger.error("<br/>  FhglOrderDelivery/Sle_ODYContractID  <br/> Pstr = " + Pstr + " <br/> ip =  " + ip + " <br/> ",e.getCause().toString());
        }
        return Myerr("获取 合同发货信息 ID 操作失败！");
    }




}
